package base.http.rxandroid

import base.utils.SysUtils
import base.view.CommonDialog
import com.tange.ai.iot.client.gnssa.R
import io.reactivex.annotations.Nullable
import io.reactivex.functions.Consumer
import org.reactivestreams.Subscription

/**
 * @author jjw
 * Created by jjw on 2018/5/7.
 */
class CustomConsumer(val activity: androidx.fragment.app.FragmentActivity, @Nullable val dialog: CommonDialog) : Consumer<Subscription> {

    override fun accept(s: Subscription) {
        dialog.setLayoutId(R.layout.layout_loading)
        dialog.setAnimStyle(-1)
                .setDimAmount(0f)
                .setHeight((SysUtils.getScreenHeight(activity) * 0.3).toInt())
                .setWidth((SysUtils.getScreenHeight(activity) * 0.3).toInt())
                .showDialog(activity.supportFragmentManager, "dialog")
        dialog.setOutCancel(true)
    }

    fun dismiss() {
        dialog.dismissDialog()
    }
}